package com.baize.baizeapp.test.jetpack2

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.launch
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class HospitalViewModel : ViewModel() {


    //viewModelScope是一个绑定到当前viewModel的作用域  当ViewModel被清除时会自动取消该作用域，所以不用担心内存泄漏
    fun getHospitalInfo() {
        viewModelScope.launch {
            val retrofit = Retrofit.Builder()
                .baseUrl("https://apihospital.ipalmap.com/hospital/screen/hospital")
                .addConverterFactory(GsonConverterFactory.create())
                .build()
            val service = retrofit.create(DataService::class.java)
            service.requestQuickItem("09K302","hp")
        }
    }


}